package com.light.model;

import java.awt.*;

/**
 * @Author MoonlightL
 * @ClassName: GameElement
 * @ProjectName flappy_bird
 * @Description: 游戏元素
 * @DateTime 2023/3/13, 0013 14:03
 */
public abstract class GameElement extends Component {

    private int x;

    private int y;

    private int width;

    private int height;

    private Image image;

    public GameElement(int x, int y, Image image) {
        this.x = x;
        this.y = y;
        this.image = image;
        this.width = image.getWidth(null);
        this.height = image.getHeight(null);
    }

    public void draw(Graphics2D g) {
        g.drawImage(this.image, this.x, this.y, null);
    }

    public abstract void reset();

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }
}
